package com.sds.shop.action;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sds.fw.mvc.Action;
import com.sds.fw.mvc.HttpUtil;
import com.sds.shop.dao.BoardDAO;
import com.sds.shop.dao.ReplyDAO;
import com.sds.shop.vo.BoardVO;
import com.sds.shop.vo.ReplyVO;

public class BoardDetailAction extends Action{
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		try{
			String board_no = request.getParameter("board_no");
			
			BoardDAO.getInstance().increaseCountBoard(board_no);
			BoardVO board = BoardDAO.getInstance().getBoardDetail(Integer.parseInt(board_no));
			ArrayList<ReplyVO> replyList = ReplyDAO.getInstance().getReplyList(board_no);
						
			request.setAttribute("replyList", replyList);
			request.setAttribute("board", board);
			HttpUtil.forward(request, response, "/jsp/boardDetail.jsp");
		}
		catch(Exception e){
			System.out.println("in BoardDetailAction");
			System.out.println(e);
		}
	}
}
